//****************************************************
// Porman Project 2
// Filename: CFramebufferObject.h
// Date: 2009/05/30
// Author: KengYu Lin
// Modify:
//****************************************************
#ifndef _CFRAMEBUFFEROBJECT_H
#define _CFRAMEBUFFEROBJECT_H
#include "CBaseObject.h"

namespace Porman
{

namespace GL
{

class CTextureObject;
class CDepthStencilObject;

class CFramebufferObject : public CBaseObject
{
    friend class CRenderDevice;
public:
    PGL_API virtual void setName( const char* pName ) { m_sName = std::string("FBufObj_") + std::string( pName ); }

    PGL_API void setRenderTarget2D( ERenderTargetAttachment enumAttachment, int iLevel, CTexture2DObject* pTextureObj );
    PGL_API void setRenderTarget3D( ERenderTargetAttachment enumAttachment, int iLevel, int iOffset, CTexture3DObject* pTextureObj );
    PGL_API void setRenderTargetCube( ERenderTargetAttachment enumAttachment, CTextureCubeObject::ETexCubeFace enumType, int iLevel, CTextureCubeObject* pTextureObj );
    PGL_API void setDepthStencilTarget( CDepthStencilObject* pDepthStencilObj );

protected:
    CFramebufferObject( CRenderDevice* pDevice );
    virtual ~CFramebufferObject( void );

protected:
    struct SData
    {
    public:
        SData( void );
        ~SData( void );

        void clear( void );
        int parse( int iIndex );

    public:
        CTexture2DObject*                m_pTex2D;
        CTexture3DObject*                m_pTex3D;
        CTextureCubeObject*              m_pTexCube;
        CTextureCubeObject::ETexCubeFace m_eType;
        CDepthStencilObject*             m_pDS;

        int m_iColorAttachment;
        int m_iDepthAttachment;
        int m_iStencilAttachment;
        int m_iLevel;
        int m_iOffset;
    };

protected:
    SData m_Datas[9]; //0~7 is used by Texture or Render obj for MRT and 8 is used by StencilDepth obj.
};

}//End namespace GL

}//End namespace Porman

#endif